home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / TUTORIAL / 0222.ZIP / GETSEC.ASM < prev    next >
Assembly Source File  |  1982-08-26  |  3KB  |  71 lines

  1. PAGE 50,132
  2. TITLE GETSEC5   -PASCAL FUNCTION TO GET DISK SECTORS
  3. ;GETSEC --  Pascal Function to get sectors from disk using DOS's INT 25H.
  4. ;            Interfaces to IBM PC Pascal v1.00 Compiler (Microsoft).
  5. ;            see DOS Manual, page D-25; and Tech Ref Manual, page A-32.
  6. ;***********  (c) Copyright 1982 by Walter H. Rauser   5-16-82   ***********
  7. ;{sample of Pascal declarations to use GETSEC}
  8. ;function GETSEC(drive  :integer;    {A is 0, B is 1, C is 2, D is 3}
  9. ;                 first  :integer;    {first sector # in 0-origin}
  10. ;                 numof  :integer;     {number of sectors to get}
  11. ;             var buffer :dirtype;    {buffer to hold all fetched sectors}
  12. ;             var errorc :integer    {DOS error code}
  13. ;                       ):boolean; EXTERN;
  14. ;{sample of buffer type for directory sectors, DOS 1.10}
  15. ;type dirtype = array[1..112] of record        {112 for DS Drives, 64 for SS}
  16. ;                    name    [0]:string(8);
  17. ;                    ext        [8]:string(3);
  18. ;                    attr   [11]:byte;
  19. ;                    resvd  [12]:array[1..10] of byte;
  20. ;                    time   [22]:word;
  21. ;                    date   [24]:word;
  22. ;                 cluster1  [26]:word;
  23. ;                 sizelow   [28]:word;
  24. ;                 sizehigh  [30]:word;
  25. ;                end;    
  26. ; frame contents for call from Pascal
  27. ; offset len  variable     attributes
  28. ; [BP]+14  2  drive            int value parameter
  29. ; [BP]+12  2  firstsector     int value parameter
  30. ; [BP]+10  2  numofsectors     int value param
  31. ; [BP]+ 8  2  buffer              var param
  32. ; [BP]+ 6  2  errorcode     int var param 
  33. ; [BP]+ 4  2  CS:         return address long call
  34. ; [BP]+ 2  2  offset      return address
  35. ; [BP]+ 0  2  old frame pointer storage
  36. ;
  37. ;
  38. MYSEG    SEGMENT    PARA    PUBLIC    'CODE'
  39.         ASSUME CS:MYSEG
  40.         PUBLIC GETSEC
  41. ;
  42. GETSEC     PROC    FAR
  43.         PUSH    BP                ;save old frame pointer
  44.         MOV        BP,SP            ;set new frame pointer
  45.         MOV        AX,[BP].14        ;put drive num into AL
  46.         XOR        AH,AH
  47.         MOV        CX,[BP].10        ;num of sectors to fetch
  48.         MOV        DX,[BP]+12        ;logical record # of first sec, 0-orgin
  49.         PUSH    DS                ;restore before ret
  50.         PUSH    SS                ;buffer is in stack segment
  51.         POP        DS                ;DS: of buffer (transfer address)
  52. ;
  53.         MOV        BX,[BP]+8        ;offset of buffer
  54.         INT        25H                ;absolute disk read, DOS function.
  55.         JC        ERROR            ;error if carry flag set
  56.         MOV        AL,01H            ; okay, set AL to return GETSEC=true 
  57.         JMP        DONE
  58. ;
  59. ERROR:    MOV        BP,[BP].6        ;adr of errorc
  60.         MOV      [BP],AX            ;dos error code
  61.         MOV        AL,00H            ; error, set AL to return GETSEC=false
  62. ;
  63. DONE:    XOR        AH,AH
  64.         POPF                    ;int 25H left Flags on stack
  65.         POP        DS                ;restore DS
  66.         POP        BP                ;restore frame pointer
  67.         RET        10                ;clear parameters from stack
  68. GETSEC    ENDP
  69. MYSEG    ENDS
  70.         END 
  71.